package com.chinasofti.thread04;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;


public class MyCallable implements Callable<String> {
    @Override
    public String call() {
        for (int i=0;i<100;i++){
            System.out.println(Thread.currentThread().getName()+"---"+i);
        }
        return "线程执行完毕";
    }
}

class Demo{
    public static void main(String[] args) throws InterruptedException {
        MyCallable mc = new MyCallable();
        FutureTask<String> ft = new FutureTask<>(mc);

        Thread t1 = new Thread(ft);
        t1.setName("舒克1");
        t1.setPriority(1);
        t1.start();

        MyCallable mc2 = new MyCallable();
        FutureTask<String> ft2 = new FutureTask<>(mc2);
        Thread t2 = new Thread(ft2);
        t2.setName("贝塔2");
        t2.setPriority(10);
        t2.start();
    }
}